package com.spm.study.demoproject.area.publicInterface.service.impl;

import com.spm.study.demoproject.area.base.serviceException.SelectException;
import com.spm.study.demoproject.area.publicInterface.entity.Staff;
import com.spm.study.demoproject.area.publicInterface.mapper.CurrentMapper;
import com.spm.study.demoproject.area.publicInterface.service.CurrentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author aiya
 */
@Service
public class CurrentServiceImpl implements CurrentService {

    @Resource
    private CurrentMapper currentMapper;

    @Override
    public Staff getStaffByToken(String token) {
        return currentMapper.getStaffByToken(token);
    }

    @Override
    public Staff getStaffByPhone(String phone) {
        Staff staff = null;
        try {
            staff = currentMapper.getStaffByPhone(phone);
        }catch (Exception e){
            throw new SelectException("手机号查询出现错误！");
        }
        if (staff == null){
            throw new SelectException("手机号未查询到具体信息，请联系部门人事！");
        }
        return staff;
    }

    @Override
    public Staff getStaffByNo(String empno) {
        return currentMapper.getStaffByNo(empno);
    }

    @Override
    public Staff getStaffByEno(String empno) {
        return currentMapper.getStaffByEno(empno);
    }

    @Override
    public Staff getStaffByEmpnoAndPost(String empno, String post) {
        return currentMapper.getStaffByEmpnoAndPost(empno,post);
    }
}
